package memento.theory;

public class Client {
    public static void main(String[] args) {
        Originator originator = new Originator();
        Caretaker caretaker = new Caretaker();

        // 设置状态1
        originator.setState("state 1");

        // 保存状态
        Memento memento1 = originator.saveState();
        caretaker.add(memento1);

        // 设置状态2
        originator.setState("state 2");

        // 保存状态
        Memento memento2 = originator.saveState();
        caretaker.add(memento2);


        // 恢复状态
        originator.getStateFromMento(caretaker.get(0));
        System.out.println(originator.getState());
        originator.getStateFromMento(caretaker.get(1));
        System.out.println(originator.getState());
    }
}
